<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script type="text/javascript" src="../js/vue.js"></script>
  <title>列表渲染</title>
</head>
<body>
  <div id="root">
    <h2>key的原理</h2>
    <hr>
    <div>
      <button @click="addPersion">添加persion</button>
      <ul >
        <!-- <li v-for="(p,index) of persion" :key="index"> -->
          <li v-for="(p,index) of persion">
          {{ p.name }} -- {{ p.age }}
          <input type="text" :value=" p.name +'——'+ p.age ">
        </li>
      </ul>
    </div>
  </div>
  <script type="text/javascript">
    const x= new Vue({
      el:'#root', 
      data:{ 
        persion: [
          {id:'sk9G2O01avD',name:'张三',age:'12'},
          {id:'k8F4Dl7m',name:'李四',age:'34'},
          {id:'oB5vA0Qmm1p',name:'杰克',age:'22'}
        ]
      },
      methods: {
        addPersion() {
          this.persion.unshift({id:'y3fT0Mq21Do',name:'王五',age:'28'},)
        }
      },
    })
  </script>
</body>
</html>